/**
 ******************************************************************************
 * @file    zb32l03x_hal_uart_irda.h
 * @author  MCU Application Team
 * @Version V0.0.1
 * @Date    2022/12/15
 * @brief   Header file of UART IrDA HAL module.
 *
 ******************************************************************************
 */



#ifndef __ZB32L03x_HAL_UART_IRDA_H
#define __ZB32L03x_HAL_UART_IRDA_H

#include "zb32l03x_hal.h"

#ifdef __cplusplus
extern "C" {
#endif

/** @defgroup  UART IrDA Interrupt Flag with INTSR Register definition.
  * @{
  */
#define UART_IRDA_FLAG_RXNE                     ((uint32_t)UART_INTSR_RI)
#define UART_IRDA_FLAG_TC                       ((uint32_t)UART_INTSR_TI)
#define UART_IRDA_FLAG_FE                       ((uint32_t)UART_INTSR_FE)

/** @defgroup  UART IrDA Enable or Disable NVIC Interrupt Flag  definition.
  * @{
  */
#define UART_IRDA_IT_RIEN                       ((uint32_t)UART_SCON_RIEN)
#define UART_IRDA_IT_TIEN                       ((uint32_t)UART_SCON_TIEN)
#define UART_IRDA_IT_FEEN                       ((uint32_t)UART_SCON_FEEN)

#define UART_IRDA_IT_MASK                       ((uint32_t)(UART_SCON_RIEN | UART_SCON_TIEN | UART_SCON_FEEN))

/** @defgroup UART_InterruptDisable_definition  UART InterruptDisable Definitions
 * @{
 */
#if defined(UART_INTDIS_RIDIS)

#define UART_IRDA_INTDIS_FE                          ((uint32_t)(UART_INTDIS_FEDIS))
#define UART_IRDA_INTDIS_TI                          ((uint32_t)(UART_INTDIS_TIDIS))
#define UART_IRDA_INTDIS_RI                          ((uint32_t)(UART_INTDIS_RIDIS))
#define IRDA_INTDIS_MASK                             (UART_IRDA_INTDIS_FE | UART_IRDA_INTDIS_TI | UART_IRDA_INTDIS_RI)

#endif

/**
 * @brief HAL UART State structures definition
 * @note  HAL UART State value is a combination of 2 different substates: gState and RxState.
 *        - gState contains UART state information related to global Handle management
 *          and also information related to Tx operations.
 *          gState value coding follow below described bitmap :
 *          b7-b6  Error information
 *             00 : No Error
 *             01 : (Not Used)
 *             10 : Timeout
 *             11 : Error
 *          b5     IP initialisation status
 *             0  : Reset (IP not initialized)
 *             1  : Init done (IP initialized. HAL UART Init function already called)
 *          b4-b3  (not used)
 *             xx : Should be set to 00
 *          b2     Intrinsic process state
 *             0  : Ready
 *             1  : Busy (IP busy with some configuration or internal operations)
 *          b1     (not used)
 *             x  : Should be set to 0
 *          b0     Tx state
 *             0  : Ready (no Tx operation ongoing)
 *             1  : Busy (Tx operation ongoing)
 *        - RxState contains information related to Rx operations.
 *          RxState value coding follow below described bitmap :
 *          b7    (not used)
 *             xx : Should be set to 0
 *          b6     Addressing transfer status
 *             0  : Reset (No addressing communication takes place)
 *             1  : Busy (Addressing communication)
 *          b5     IP initialisation status
 *             0  : Reset (IP not initialized)
 *             1  : Init done (IP initialized)
 *          b4-b2  (not used)
 *            xxx : Should be set to 000
 *          b1     Rx state
 *             0  : Ready (no Rx operation ongoing)
 *             1  : Busy (Rx operation ongoing)
 *          b0     (not used)
 *             x  : Should be set to 0.
 */
typedef enum
{
    HAL_UART_IRDA_STATE_RESET               = 0x00U,    /*!< Peripheral is not yet Initialized
                                                            Value is allowed for gState and RxState */
    HAL_UART_IRDA_STATE_READY               = 0x20U,    /*!< Peripheral Initialized and ready for use
                                                            Value is allowed for gState and RxState */
    HAL_UART_IRDA_STATE_BUSY                = 0x24U,    /*!< an internal process is ongoing
                                                            Value is allowed for gState only */
    HAL_UART_IRDA_STATE_BUSY_TX             = 0x21U,    /*!< Data Transmission process is ongoing
                                                            Value is allowed for gState only */
    HAL_UART_IRDA_STATE_BUSY_RX             = 0x22U,    /*!< Data Reception process is ongoing
                                                            Value is allowed for RxState only */
    HAL_UART_IRDA_STATE_BUSY_RX_ADDRESS     = 0x62U,    /*!< Address frame data Reception process is ongoing
                                                            Value is allowed for RxState only */
    HAL_UART_IRDA_STATE_TIMEOUT             = 0xA0U,    /*!< Timeout state
                                                            Value is allowed for gState only */
    HAL_UART_IRDA_STATE_ERROR               = 0xE0U     /*!< Error
                                                            Value is allowed for gState only */
} HAL_UART_IrDA_StateTypeDef;


/** @defgroup UART_Exported_Constants UART Exported constants
 * @{
 */

/** @defgroup UART_Error_Code UART Error Code
 * @{
 */
typedef enum
{
    HAL_UART_IRDA_ERROR_NONE    = (uint32_t)0x00000000U,          /*!< No error            */

    HAL_UART_IRDA_ERROR_CONFIG  = (uint32_t)0x00000001U,          /*!< Configure error     */

    HAL_UART_IRDA_ERROR_PARITY  = (uint32_t)0x00000002U,          /*!< Parity error        */

    HAL_UART_IRDA_ERROR_FE      = (uint32_t)0x00000004U,          /*!< Frame error         */

    HAL_UART_IRDA_ERROR_TIMEOUT = (uint32_t)0x00000008U           /*!< Wait time out       */

} HAL_UART_IrDA_ErrorCodeTypeDef;

/** End of UART_Error_Code
 * @}
 */

/** @defgroup UART_BaudDouble UART Baudrate doubled
 * @{
 */
typedef enum
{
    UART_IRDA_BAUDDOUBLE_DISABLE    = (uint32_t)0x00000000U,

    UART_IRDA_BAUDDOUBLE_ENABLE     = (uint32_t)(UART_SCON_DBAUD),

} HAL_UART_IrDA_BaudDoubleTypeDef;

/** End of UART_BaudDouble
 * @}
 */


/** @defgroup UART_ProgTimer UART Pprogrammable Timer enable or disable
 * @{
 */
typedef enum
{
    UART_IRDA_PROG_TIMER_DISABLE        = (uint32_t)0x00000000U,

    UART_IRDA_PROG_TIMER_ENABLE         = (uint32_t)(UART_BAUDCR_SELF_BRG),

} HAL_UART_IrDA_ProgTimerTypeDef;

/** End of UART_ProgTimer
 * @}
 */


/** @defgroup UART_Word_Length UART Word Length
 * @{
 */
typedef enum
{
    UART_IRDA_WORDLENGTH_8B             = (uint32_t)(UART_SCON_SM0_SM1_MODE_1 << UART_SCON_SM0_SM1_Pos),

    UART_IRDA_WORDLENGTH_9B             = (uint32_t)(UART_SCON_SM0_SM1_MODE_3 << UART_SCON_SM0_SM1_Pos),

} HAL_UART_IrDA_WordLengthTypeDef;

/** End of UART_Word_Length
 * @}
 */


/** @defgroup UART_Parity  UART Parity
 * @{
 */
typedef enum
{
    UART_IRDA_PARITY_NONE               = (uint32_t)0x00000000U,

    UART_IRDA_PARITY_EVEN               = (uint32_t)0x00000001U,

    UART_IRDA_PARITY_ODD                = (uint32_t)0x00000002U,

} HAL_UART_IrDA_ParityTypeDef;

/** End of UART_Parity
 * @}
 */


/** @defgroup UART_Mode UART Transfer Mode
 * @{
 */
typedef enum
{
    UART_IRDA_MODE_TX                   = (uint32_t)0x00000000U,

    UART_IRDA_MODE_RX                   = (uint32_t)(UART_SCON_REN),

    UART_IRDA_MODE_TX_RX                = (uint32_t)(UART_SCON_REN),

} HAL_UART_IrDA_ModeTypeDef;

/** End of UART_Mode
 * @}
 */


/** @defgroup UART_IrDA_TranInversion UART Trnasmit Level Inversion
 * @{
 */
typedef enum
{
    UART_IRDA_IRTXINV_DISABLE           = (uint32_t)0x00000000,

    UART_IRDA_IRTXINV_ENABLE            = (uint32_t)(UART_IRDACR_IRTXINV),

} HAL_UART_IrDA_TranInversionTypeDef;

/** End of UART_IrDA_TranInversion
 * @}
 */


/** @defgroup UART_IrDA_ReceInversion UART Receive Level Inversion
 * @{
 */
typedef enum
{
    UART_IRDA_IRRXINV_DISABLE           = (uint32_t)0x00000000,

    UART_IRDA_IRRXINV_ENABLE            = (uint32_t)(UART_IRDACR_IRRXINV),

} HAL_UART_IrDA_ReceInversionTypeDef;

/** End of UART_IrDA_ReceInversion
 * @}
 */


/** @defgroup UART_IrDA_PowerMode UART IrDA Power Mode
 * @{
 */
typedef enum
{
    UART_IRDA_NORMAL_MODE               = (uint32_t)0x00000000,

    UART_IRDA_LOWPOWER_MODE             = (uint32_t)(UART_IRDACR_IRLPMODE),

} HAL_UART_IrDA_PowerModeTypeDef;

/** End of UART_IrDA_PowerMode
 * @}
 */


/** End of UART_Exported_Constants
 * @}
 */

/**
 * @brief UART IrDA Init Structure definition
 */
typedef struct
{
    uint32_t                            BaudRate;               /*!< This member configures the UART communication baud rate. */

    HAL_UART_IrDA_BaudDoubleTypeDef     BaudDouble;             /*!< Specifies whether baudrate is doubled. */

    HAL_UART_IrDA_ModeTypeDef           Mode;                   /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. */

    HAL_UART_IrDA_ParityTypeDef         Parity;                 /*!< Specifies the parity mode. */

    HAL_UART_IrDA_PowerModeTypeDef      PowerMode;              /*!< Specifies whether the Module power consumption Settings . */

    HAL_UART_IrDA_ProgTimerTypeDef      ProgTimer;              /*!< Specifies whether programable timer is enabled. */

    HAL_UART_IrDA_TranInversionTypeDef  TranInversion;          /*!< Specifies whether Inversion is enabled. */

    HAL_UART_IrDA_ReceInversionTypeDef  ReceInversion;          /*!< Specifies whether Inversion is enabled. */

    HAL_UART_IrDA_WordLengthTypeDef     WordLength;             /*!< Specifies the number of data bits transmitted or received in a frame. */

    uint8_t                             Prescaler;              /*!< This member configures the UART_IrDA communication Prescaler. */

    uint8_t                             SlaveAddr;              /*!< This member configures the UART communication Slave Address. */

    uint8_t                             SlaveAddrMask;          /*!< This member configures the UART communication Slave Address Mask. */

} UART_IrDA_InitTypeDef;


/**
 * @brief  UART IrDA handle Structure definition
 */
typedef struct
{
    UART_TypeDef                        *Instance;        /*!< UART registers base address                      */

    UART_IrDA_InitTypeDef               Init;             /*!< IRDA communication parameters                    */

    uint8_t                             *pTxBuffPtr;      /*!< Pointer to UART Tx transfer Buffer               */

    uint16_t                            TxXferSize;       /*!< UART Tx Transfer size                            */

    __IO uint16_t                       TxXferCount;      /*!< UART Tx Transfer Counter                         */

    uint8_t                             *pRxBuffPtr;      /*!< Pointer to UART Rx transfer Buffer               */

    uint16_t                            RxXferSize;       /*!< UART Rx Transfer size                            */

    __IO uint16_t                       RxXferCount;      /*!< UART Rx Transfer Counter                         */

    HAL_LockTypeDef                     Lock;             /*!< Locking object                                   */

    __IO HAL_UART_IrDA_StateTypeDef     gState;           /*!< UART state information related to global Handle management
                                                            and also related to Tx operations.                  */

    __IO HAL_UART_IrDA_StateTypeDef     RxState;          /*!< UART state information related to Rx operations. */

    __IO HAL_UART_IrDA_ErrorCodeTypeDef ErrorCode;        /*!< IRDA Error code                                  */
} UART_IRDA_HandleTypeDef;




/** @defgroup UART_Exported_Macros UART Exported Macros
 * @{
 */


/** @brief  Checks whether the specified UART flag is set or not.
 * @param  __HANDLE__: specifies the UART Handle.
 *         This parameter can be UARTx where x: 0, 1 to select the peripheral.
 * @param  __FLAG__: specifies the flag to check.
 *        This parameter can be one of the following values:
 *            @arg UART_IRDA_FLAG_TC:   Transmission Complete flag
 *            @arg UART_IRDA_FLAG_RXNE: Receive data register not empty flag
 *            @arg UART_IRDA_FLAG_FE:   Framing Error flag
 * @retval The new state of __FLAG__ (TRUE or FALSE).
 */
#define __HAL_UART_IRDA_GET_FLAG(__HANDLE__, __FLAG__)           (((__HANDLE__)->Instance->INTSR & (__FLAG__)) == (__FLAG__))

/** @brief  Clears the specified UART pending flag.
 * @param  __HANDLE__: specifies the UART Handle.
 *         This parameter can be UARTx where x: 0, 1 to select the peripheral.
 * @param  __FLAG__: specifies the flag to check.
 *        This parameter can be one of the following values:
 *            @arg UART_IRDA_FLAG_TC:   Transmission Complete flag
 *            @arg UART_IRDA_FLAG_RXNE: Receive data register not empty flag
 *            @arg UART_IRDA_FLAG_FE:   Framing Error flag
 *
 * @note   TC, FE, RXNE flag should be cleared by software.
 *
 */
#define __HAL_UART_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__)         ((__HANDLE__)->Instance->INTCLR |= (__FLAG__))

/** @brief  Enable the specified UART interrupt.
 * @param  __HANDLE__: specifies the UART Handle.
 *         UART Handle selects the UARTx peripheral
 * @param  __INTERRUPT__: specifies the UART interrupt source to enable.
 *          This parameter can be one of the following values:
 *            @arg UART_IRDA_IT_TIEN:   Transmission complete interrupt
 *            @arg UART_IRDA_IT_RIEN: Receive Data register not empty interrupt
 *            @arg UART_IRDA_IT_FEEN: Fream error check interrupt
 */
#define __HAL_UART_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__)     ((__HANDLE__)->Instance->SCON |= ((__INTERRUPT__) & UART_IRDA_IT_MASK))

/** @brief  Disable the specified UART interrupt.
 * @param  __HANDLE__: specifies the UART Handle.
 *         UART Handle selects the UARTx peripheral
 * @param  __INTERRUPT__: specifies the UART interrupt source to disable.
 *          This parameter can be one of the following values:
 *            @arg UART_IRDA_IT_TIEN:  Transmission complete interrupt
 *            @arg UART_IRDA_IT_RIEN: Receive Data register not empty interrupt
 *            @arg UART_IRDA_IT_FEEN: Fream error check interrupt
 */
#define __HAL_UART_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__)    ((__HANDLE__)->Instance->SCON &= ~ ((__INTERRUPT__) & UART_IRDA_IT_MASK))

/** @brief  Checks whether the specified UART interrupt has occurred or not.
 * @param  __HANDLE__: specifies the UART Handle.
 *         UART Handle selects the UARTx peripheral
 * @param  __IT__: specifies the UART interrupt source to check.
 *          This parameter can be one of the following values:
 *            @arg UART_IRDA_IT_TIEN: Transmission complete interrupt
 *            @arg UART_IRDA_IT_RIEN: Receive Data register not empty interrupt
 *            @arg UART_IRDA_IT_FEEN: Fream error check interrupt
 * @retval The new state of __IT__ (TRUE or FALSE).
 */
#define __HAL_UART_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__)        ((__HANDLE__)->Instance->SCON) & (((uint32_t)(__IT__)) & UART_IRDA_IT_MASK))

/** @brief  Disable UART IrDA module.
  * @param  __HANDLE__ specifies the UART Handle.
  * @retval None
  */
#define __HAL_UART_IRDA_DISABLE(__HANDLE__)                      CLEAR_BIT(((__HANDLE__)->Instance->IRDACR), UART_IRDACR_IREN)

/** @brief  Enable UART IrDA module.
  * @param  __HANDLE__ specifies the UART Handle.
  * @retval None
  */
#define __HAL_UART_IRDA_ENABLE(__HANDLE__)                       SET_BIT(((__HANDLE__)->Instance->IRDACR), UART_IRDACR_IREN)

#if defined(UART_INTDIS_RIDIS)
/** @brief  UART enables to send signal to NVIC.
 * @param  __HANDLE__: specifies the UART Handle.
 *         UART Handle selects the UARTx peripheral
 * @param  __INTERRUPT__: specifies the UART interrupt source to enable.
 *          This parameter can be one of the following values:
 *            @arg UART_IRDA_INTDIS_FE: Disable receiving frame error interrupt
 *            @arg UART_IRDA_INTDIS_TI: Disable transmission complete interrupt
 *            @arg UART_IRDA_NTDIS_RI: Disable receive completion interrupt
 */
#define __HAL_UART_IRDA_ENABLE_INTDIS(__HANDLE__, __INTERRUPT__)     SET_BIT((__HANDLE__)->Instance->INTDIS, (__INTERRUPT__) & IRDA_INTDIS_MASK)


/** @brief  UART disables to send signal to NVIC.
 * @param  __HANDLE__: specifies the UART Handle.
 *         UART Handle selects the UARTx peripheral
 * @param  __INTERRUPT__: specifies the UART interrupt source to disable.
 *          This parameter can be one of the following values:
 *            @arg UART_IRDA_INTDIS_FE: Disable receiving frame error interrupt
 *            @arg UART_IRDA_INTDIS_TI: Disable transmission complete interrupt
 *            @arg UART_IRDA_INTDIS_RI: Disable receive completion interrupt
 */
#define __HAL_UART_IRDA_DISABLE_INTDIS(__HANDLE__, __INTERRUPT__)    CLEAR_BIT((__HANDLE__)->Instance->INTDIS, (__INTERRUPT__) & IRDA_INTDIS_MASK)

#endif



/** End of UART_Exported_Macros
 * @}
 */


/** @addtogroup UART_IrDA_Exported_Functions
 * @{
 */

/** @addtogroup UART_IrDA_Exported_Functions_Group1
 * @{
 */
/* Initialization/de-initialization functions  **********************************/
HAL_StatusTypeDef HAL_UART_IrDA_Init(UART_IRDA_HandleTypeDef *pHIrda);
HAL_StatusTypeDef HAL_UART_IrDA_DeInit (UART_IRDA_HandleTypeDef *pHIrda);
void HAL_UART_IrDA_MspInit(UART_IRDA_HandleTypeDef *pHIrda);
void HAL_UART_IrDA_MspDeInit(UART_IRDA_HandleTypeDef *pHIrda);

uint16_t HAL_UART_IRDA_CalcProgTimerPeriod(UART_IRDA_HandleTypeDef *pHIrda);

/** End of UART_IrDA_Exported_Functions_Group1
 * @}
 */

 /** @addtogroup UART_IrDA_Exported_Functions_Group2
 * @{
 */
/* IO operation functions *******************************************************/
HAL_StatusTypeDef HAL_UART_IRDA_Transmit(UART_IRDA_HandleTypeDef *pHIrda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_UART_IRDA_Receive(UART_IRDA_HandleTypeDef *pHIrda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_UART_IRDA_TransmitReceive(UART_IRDA_HandleTypeDef *pHIrda, uint8_t* ptxBuff, uint16_t txSize, uint8_t* prxBuff, uint16_t rxSize, uint32_t Timeout);
HAL_StatusTypeDef HAL_UART_IRDA_ReceiveTransmit(UART_IRDA_HandleTypeDef *pHIrda, uint8_t* ptxBuff, uint16_t txSize, uint8_t* prxBuff, uint16_t rxSize, uint32_t Timeout);
HAL_StatusTypeDef HAL_UART_IRDA_Transmit_IT(UART_IRDA_HandleTypeDef *pHIrda, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_UART_IRDA_Receive_IT(UART_IRDA_HandleTypeDef *pHIrda, uint8_t *pData, uint16_t Size);

HAL_StatusTypeDef HAL_UART_IRDA_Transmit_Addressing(UART_IRDA_HandleTypeDef *pHIrda, uint8_t slaveAddr, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_UART_IRDA_Receive_Addressing(UART_IRDA_HandleTypeDef *pHIrda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_UART_IRDA_Transmit_Addressing_IT(UART_IRDA_HandleTypeDef *pHIrda, uint8_t slaveAddr, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef HAL_UART_IRDA_Receive_Addressing_IT(UART_IRDA_HandleTypeDef *pHIrda, uint8_t *pData, uint16_t Size);

/* Transfer Abort functions */
HAL_StatusTypeDef HAL_UART_IRDA_Abort(UART_IRDA_HandleTypeDef *pHIrda);
HAL_StatusTypeDef HAL_UART_IRDA_AbortTransmit(UART_IRDA_HandleTypeDef *pHIrda);
HAL_StatusTypeDef HAL_UART_IRDA_AbortReceive(UART_IRDA_HandleTypeDef *pHIrda);


void HAL_UART_IRDA_IRQHandler(UART_IRDA_HandleTypeDef *pHIrda);
void HAL_UART_IRDA_TxCpltCallback(UART_IRDA_HandleTypeDef *pHIrda);
void HAL_UART_IRDA_RxCpltCallback(UART_IRDA_HandleTypeDef *pHIrda);
void HAL_UART_IRDA_ErrorCallback(UART_IRDA_HandleTypeDef *pHIrda);
void HAL_UART_IRDA_AbortCpltCallback(UART_IRDA_HandleTypeDef *pHIrda);
void HAL_UART_IRDA_AbortTransmitCpltCallback(UART_IRDA_HandleTypeDef *pHIrda);
void HAL_UART_IRDA_AbortReceiveCpltCallback(UART_IRDA_HandleTypeDef *pHIrda);

/** End of UART_IrDA_Exported_Functions_Group2
 * @}
 */

/** @addtogroup UART_IrDA_Exported_Functions_Group3
 * @{
 */
/* Peripheral State functions  **************************************************/
uint32_t HAL_UART_IRDA_GetState(UART_IRDA_HandleTypeDef *pHIrda);
uint32_t HAL_UART_IRDA_GetError(UART_IRDA_HandleTypeDef *pHIrda);



/** End of UART_IrDA_Exported_Functions_Group3
 * @}
 */


/** End of UART_IrDA_Exported_Functions
 * @}
 */


/** @defgroup UART_IrDA_Private_Macros UART Private Macros
 * @{
 */
#if defined(CONFIG_USE_ZB32L003) || defined(CONFIG_USE_ZB32L032)

    #define IS_UART_IRDA_INSTANCE(INSTANCE)             ((INSTANCE) == UART0 || (INSTANCE) == UART1)

#elif defined(CONFIG_USE_ZB32L030)

    #define IS_UART_IRDA_INSTANCE(INSTANCE)             ((INSTANCE) == UART0 || (INSTANCE) == UART1 || \
                                                         (INSTANCE) == UART2 || (INSTANCE) == UART3)

#endif

#define IS_UART_IRDA_BAUDRATE(BAUDRATE)                 ((BAUDRATE) <= 115200U)

#define IS_UART_IRDA_BAUDDOUBLE(BAUDDOUBLE)             ((BAUDDOUBLE) == UART_IRDA_BAUDDOUBLE_DISABLE || \
                                                         (BAUDDOUBLE) == UART_IRDA_BAUDDOUBLE_ENABLE )

#define IS_UART_IRDA_MODE(MODE)                         ((MODE) == UART_IRDA_MODE_TX || (MODE) == UART_IRDA_MODE_RX || \
                                                         (MODE) == UART_IRDA_MODE_TX_RX )

#define IS_UART_IRDA_PARITY(PARITY)                     ((PARITY) == UART_IRDA_PARITY_NONE || (PARITY) == UART_IRDA_PARITY_EVEN || \
                                                         (PARITY) == UART_IRDA_PARITY_ODD )

#define IS_UART_IRDA_POWERMODE(POWERMODE)               ((POWERMODE) == UART_IRDA_NORMAL_MODE || (POWERMODE) == UART_IRDA_LOWPOWER_MODE )

#define IS_UART_IRDA_PROGTIMER(PROGTIMER)               ((PROGTIMER) == UART_IRDA_PROG_TIMER_DISABLE || (PROGTIMER) == UART_IRDA_PROG_TIMER_ENABLE )

#define IS_UART_IRDA_TRANINVERSION(TRANINVERSION)       ((TRANINVERSION) == UART_IRDA_IRTXINV_DISABLE || (TRANINVERSION) == UART_IRDA_IRTXINV_ENABLE)

#define IS_UART_IRDA_RECEINVERSION(RECEINVERSION)       ((RECEINVERSION) == UART_IRDA_IRRXINV_DISABLE || (RECEINVERSION) == UART_IRDA_IRRXINV_DISABLE)

#define IS_UART_IRDA_WORDLENGTH(WORDLENGTH)             ((WORDLENGTH) == UART_IRDA_WORDLENGTH_8B || (WORDLENGTH) == UART_IRDA_WORDLENGTH_9B)

#define IS_UART_IRDA_PRESCALER(PRESCALER)               ((PRESCALER) <= 255U)


/** End of UART_IrDA_Private_Macros
 * @}
 */






#ifdef __cplusplus
}
#endif

#endif  /*__HAL_UART_IRDA_H*/
